-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix the doc-comment-decoration-trimming edge-case rustdoc ICE #47210
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merged
bors
merged 1 commit into
rust-lang:master
from
zackmdavis:the_3rd_of_2_hardest_problems_in_computer_science
Jan 9, 2018
Merged
fix the doc-comment-decoration-trimming edge-case rustdoc ICE #47210
bors
merged 1 commit into
rust-lang:master
from
zackmdavis:the_3rd_of_2_hardest_problems_in_computer_science
Jan 9, 2018
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(rust_highfive has picked a reviewer for you, use r? to override) |
Can you add a test for this? Something like this:
// copyright header
// libsyntax ICE when trimming the blank line in the middle of that comment
// @has issue_47197/fn.x.html
/**
* a
* b
*/
pub fn x() { } |
This `horizontal_trim` function strips the leading whitespace from doc-comments that have a left-asterisk-margin: /** * You know what I mean— * * comments like this! */ The index of the column of asterisks is `i`, and if trimming is deemed possible, we slice each line from `i+1` to the end of the line. But if, in particular, `i` was 0 _and_ there was an empty line (as in the example given in the reporting issue), we ended up panicking trying to slice an empty string from 0+1 (== 1). Let's tighten our check to say that we can't trim when `i` is even the same as the length of the line, not just when it's greater. (Any such cases would panic trying to slice `line` from `line.len()+1`.) Resolves rust-lang#47197.
b6bde34
to
3cfea33
Compare
(updated) |
@bors r+ rollup Thanks! |
📌 Commit 3cfea33 has been approved by |
kennytm
added a commit
to kennytm/rust
that referenced
this pull request
Jan 8, 2018
…blems_in_computer_science, r=QuietMisdreavus fix the doc-comment-decoration-trimming edge-case rustdoc ICE This `horizontal_trim` function strips the leading whitespace from doc-comments that have a left-asterisk-margin: ``` /** * You know what I mean— * * comments like this! */ ``` The index of the column of asterisks is `i`, and if trimming is deemed possible, we slice each line from `i+1` to the end of the line. But if, in particular, `i` was 0 _and_ there was an empty line (as in the example given in the reporting issue), we ended up panicking trying to slice an empty string from 0+1 (== 1). Let's tighten our check to say that we can't trim when `i` is even the same as the length of the line, not just when it's greater. (Any such cases would panic trying to slice `line` from `line.len()+1`.) Resolves rust-lang#47197.
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This
horizontal_trim
function strips the leading whitespace fromdoc-comments that have a left-asterisk-margin:
The index of the column of asterisks is
i
, and if trimming is deemedpossible, we slice each line from
i+1
to the end of the line. But if, inparticular,
i
was 0 and there was an empty line (as in the examplegiven in the reporting issue), we ended up panicking trying to slice an
empty string from 0+1 (== 1).
Let's tighten our check to say that we can't trim when
i
is even the sameas the length of the line, not just when it's greater. (Any such cases
would panic trying to slice
line
fromline.len()+1
.)Resolves #47197.